package ch.il07.converter.persistence.entities;


public class User {
	private Integer userID;
	private String username;
	private String email;
	private AccessLevel accessLevel;
	private String password;
	
	public User(Integer userID, String username, String email, AccessLevel accessLevel){
		this.userID = userID;
		this.username = username;
		this.email = email;
		this.accessLevel = accessLevel;
	}
	
	/**
	 * Creates an user (default accesslevel USER).
	 * @param username Username
	 * @param password Password
	 * @param email Email
	 */
	public User(String username, String password, String email) {
		this(username, password, email, AccessLevel.USER);
	}
	
	/**
	 * Creates an user.
	 * @param username Username
	 * @param password Password (plain text)
	 * @param email Email
	 * @param accessLevel Role
	 */
	public User(String username, String password, String email,
			AccessLevel accessLevel) {
		this(null, username, password, email, accessLevel);
	}
	
	public User(Integer userID, String username, String password, String email,
			AccessLevel accessLevel){
		this.userID = userID;
		this.username = username;
		this.setPassword(password);
		this.email = email;	
		this.accessLevel = accessLevel;
	}

	@Override
	public String toString() {
		return String
				.format("[UserID=%d, Username=%s, EMail=%s, AccessLevel=%s]",
						userID, username, email, accessLevel);
	}
	
	/**
	 * @param userId the userId to set
	 */
	public void setUserID(Integer userID) {
		this.userID = userID;
	}
	/**
	 * @return the userId
	 */
	public Integer getUserID() {
		return userID;
	}
	/**
	 * @param username the username to set
	 */
	public void setUsername(String username) {
		this.username = username;
	}
	/**
	 * @return the username
	 */
	public String getUsername() {
		return username;
	}
	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}
	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}
	/**
	 * @param accessLevel the accessLevel to set
	 */
	public void setAccessLevel(AccessLevel accessLevel) {
		this.accessLevel = accessLevel;
	}
	/**
	 * @return the accessLevel
	 */
	public AccessLevel getAccessLevel() {
		return accessLevel;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPassword() {
		return password;
	}
}